Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

Community articleXpages - changing the color of a single cell in a view Panel based on a field value
Added by ~Kim Froresatherings | Edited by ~Kim Froresatherings on July 18, 2010 | Version 4
expanded Abstract
collapsed Abstract
In Lotus Notes, it is possible to add view columns that "Use value as color". This can be used to change the background color and/or text color of the entire row or just a specific cell. There are already articles on the Wiki that cover setting alternating row colors or changing the color of the entire row. This article focuses on how to change the color of just one cell depending on the value of a document.
Tags: View Column color, Xpages view column color, Xpages
The demonstration database contains products, which have "units in stock" and a "reorder level". When the standard Products view is displayed in Lotus Notes, a hidden column with "Use value as color" has been placed just before the "Units in Stock" column with the formula:
 
@If(UnitsInStock<=ReorderLevel;255:0:0:-1:-1:-1;-1:-1:-1:-1:-1:-1) 
 
This has the effect of changing the background color of the units in stock to red if the value is at or below the reorder level - time to buy some more!! 
 
The same effect is possible in Xpages. An attached PDF shows the screen shots accompanying the steps.
 
1) Add a hidden column to your view that contains the information that you will use to decide whether to apply the color or not. The column is required so that we can access the information in it once the view has been added to the Xpage. Hide it because we don't want to confuse anyone who will continue to access the native view in Lotus Notes. In this example, we already have the Units in Stock in the view, but we will also need to know the reorder level. A column was added to the view to hold the value of the reorder level.
 
2) Create a stylesheet (or modify an existing one already on the Xpage). Add in a classs with a background color: in this case 'redBackground'
 
3) Create a new XPage (or modify an existing one)
 
4) Add the stylesheet resource that contains your class to the Xpage from the Styles tab of the Properties panel for the XPage
 
5) From the Container Controls panel on the right-hand side of the Designer client, drag and drop a  "View" Control onto the XPage. In the dialog box that appears, select the view and click OK
 
6) Hide the Reorder level column and column header by unticking the "visible" property check box
 
7) To give us a way of accessing the view data, in the properties of the view panel, go to “All properties” and under the data section set the “var” property to be “rowData” 
 
8) Go to the column who's color you want to change - in this case "Units in stock". Go to the Style tab on the properties panel and click on the diamond to the right and click "Compute Value"
 
9) Enter some Javascript that will return the name of the class ("redBackground") if the units in stock are the same or less than the reorder level. To do this you will need to convert the values into numbers using parseInt or parseFloat (if you need decimal places) to compare the column values as numbers 
 

try{

var qtyReorder=parseInt(rowData.getColumnValue("Reorder Level"));

var qtyInStock=parseInt(rowData.getColumnValue("Units in Stock"));

if(qtyInStock<=qtyReorder){

return "redBackground"

}

}

catch(e){

print(e);

}

 
 10) Now save and preview in a browser.
 
A PDF containing screenshots is attached 
 
 
 
 
expanded Attachments (1)
collapsed Attachments (1)
File TypeSizeFile NameCreated OnDelete file
application/pdf 316 KB Changing the color of a single view column in a view Panel.pdf 7/18/10, 12:40 PM
expanded Versions (5)
collapsed Versions (5)
Version Comparison     
VersionDateChanged by              Summary of changes
5Aug 9, 2010, 12:56:39 PM~Andy Elresaplopettu  
This version (4)Jul 18, 2010, 12:40:56 PM~Kim Froresatherings  
3Jul 18, 2010, 12:33:30 PM~Kim Froresatherings  
2Jul 18, 2010, 12:20:31 PM~Kim Froresatherings  
1Jul 18, 2010, 11:54:01 AM~Kim Froresatherings  
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility